<template>
    <el-tree :data="data" @node-click="nodeClick" accordion></el-tree>
</template>

<script>
import axios from 'axios'   
  export default {
    data() {
      return {
        data: [],
      };
    },
    methods: {
      nodeClick(data){
        this.$emit('sendTreeData',data)
      }
    },
    mounted(){
      axios({
        url:'http://localhost:8080/kfc/admin/category/list?type=1',
        method:'get',
        headers:{
            token:localStorage.getItem('jwt')
        },
      }).then(res=>{
        console.log(res.data.data);
        for(let i=0;i<res.data.data.length;i++){
          this.data.push({label:res.data.data[i].name,value:res.data.data[i].id})
        }
      })
    }
  };
</script>

<style>

</style>